<template>
  <div class="wrapper">
    <HeaderPart>
      添加门店
    </HeaderPart>
    <div class="form">
      <el-form style="margin-top: 5rem" :model="shopInfo" label-width="80px">
        <el-form-item label="商家名称:">
          <el-input v-model="shopInfo.name" />
        </el-form-item>
        <el-form-item label="商家地址:">
          <el-input v-model="shopInfo.address" />
        </el-form-item>
        <el-form-item label="商家描述:">
          <el-input v-model="shopInfo.description" />
        </el-form-item>
        <el-form-item label="起送价格:">
          <el-input v-model="shopInfo.startPrice" />
        </el-form-item>
        <el-form-item label="配送价格:">
          <el-input v-model="shopInfo.deliveryPrice" />
        </el-form-item>
        <el-form-item label="新品介绍:">
          <el-input v-model="shopInfo.remarks" />
        </el-form-item>
        <el-form-item label="图片地址:">
          <el-input v-model="shopInfo.imgUrl" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">创建</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import {useRoute, useRouter} from "vue-router";
import {ref} from "vue";
import HeaderPart from "@/components/common/HeaderPart";
import {createShop} from "@/utils/api/ShopManager";

// 接收businessId
const businessId = parseInt(useRoute().params.businessId)
// 定义shop对象
const shopInfo = ref({businessId})
// 创建门店的方法
const router = useRouter()
const onSubmit =async ()=>{
  const res = await createShop(shopInfo.value)
  if(res.flag){
    shopInfo.value = null
    router.go(-1)
  }
}
</script>

<style scoped>
.wrapper {
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
}
.wrapper .form {
  width: 300px;
}
</style>